home *** CD-ROM | disk | FTP | other *** search
/ Computer Select (Limited Edition) / Computer Select.iso / dobbs / v16n08 / vogel.exe / TEMPLATE < prev   
Encoding:
Text File  |  1991-04-01  |  5.9 KB  |  456 lines

  1.  
  2. Here are the current templates for the "new" program.
  3.  
  4. ==============================================================================
  5.  
  6.         Template 1.    Function test driver (created using -md)
  7.  
  8. #ifndef    lint
  9. static    char    *    $n_$e_rcsid    =
  10. "$Header: $n.$e,v $r $y/$c/$d $h:$m:$s $w Exp $";
  11.  
  12. static    char    *    $n_$e_source    =
  13. "$Source$";
  14.  
  15. #endif
  16.  
  17. /*
  18.  * NAME:
  19.  *    $n
  20.  *
  21.  * SYNOPSIS:
  22.  *    $n [other option flags] args 
  23.  *
  24.  * DESCRIPTION:
  25.  *    "$n" is a test driver for the function "func".
  26.  *    $u
  27.  * OPTIONS:
  28.  *    Describe any options on the command line. 
  29.  *
  30.  * AUTHOR:
  31.  *    $x
  32.  *
  33.  * BUGS:
  34.  *    None noticed.
  35.  *
  36.  * REVISIONS:
  37.  *
  38.  * $Log$ 
  39.  */
  40.  
  41. #include    <stdio.h>
  42. #include    <strings.h>
  43.  
  44. main        (argc, argv)
  45. int        argc;
  46. char    **    argv;
  47. {
  48.  
  49. /*
  50.  *    Variables.
  51.  */
  52.  
  53.     char    *    program;
  54.     char    *    slash;
  55. $v
  56. /*
  57.  *    Store the program name and remove it from the argument list.
  58.  */
  59.  
  60.     if (slash = rindex (*argv, '/'))
  61.         program = slash + 1;
  62.     else
  63.         program = *argv;
  64.  
  65.     argv++;
  66.     argc--;
  67.  
  68. /*
  69.  *    Prepare for the call.
  70.  */
  71.  
  72.     printf ("Before call to new\n");
  73.  
  74. /*
  75.  *    Call the function.
  76.  */
  77.  
  78.     new ();
  79.     printf ("After call to new\n");
  80.     exit (0);
  81. }
  82.  
  83. ==============================================================================
  84.  
  85.         Template 2.    Generic function (created using -mf)
  86.  
  87. #ifndef    lint
  88. static    char    *    $n_$e_rcsid    =
  89. "$Header: $n.$e,v $r $y/$c/$d $h:$m:$s $w Exp $";
  90.  
  91. static    char    *    $n_$e_source    =
  92. "$Source$";
  93.  
  94. #endif
  95.  
  96. /*
  97.  * NAME:
  98.  *    $n
  99.  *
  100.  * SYNOPSIS:
  101.  *    $t $n ($l)
  102.  *
  103.  * DESCRIPTION:
  104.  *    $u
  105.  *
  106.  * ARGUMENTS:
  107.  *    Describe any function arguments.
  108.  *
  109.  * AUTHOR:
  110.  *    $x
  111.  *
  112.  * BUGS:
  113.  *    None noticed.
  114.  *
  115.  * REVISIONS:
  116.  *
  117.  * $Log$ 
  118.  */
  119.  
  120. $i
  121. $p
  122. $g
  123.  
  124. $t    $n ($l)
  125. $a{
  126.  
  127. /*
  128.  *    Functions.
  129.  */
  130.  
  131. $f
  132. /*
  133.  *    Variables.
  134.  */
  135.  
  136. $v
  137. /*
  138.  *    Processing.
  139.  */
  140.  
  141. $b
  142.     return (0);
  143. }
  144.  
  145. ==============================================================================
  146.  
  147.         Template 3.    Header file (created using -mh)
  148.  
  149. #ifndef    lint
  150. static    char    *    $n_$e_rcsid    =
  151. "$Header: $n.$e,v $r $y/$c/$d $h:$m:$s $w Exp $";
  152.  
  153. static    char    *    $n_$e_source    =
  154. "$Source$";
  155.  
  156. #endif
  157.  
  158. /*
  159.  * NAME:
  160.  *    $n.$e
  161.  *
  162.  * SYNOPSIS:
  163.  *    #include "$n.$e"
  164.  *
  165.  * DESCRIPTION:
  166.  *    Header file for "$n".
  167.  *    $u
  168.  * AUTHOR:
  169.  *    $x
  170.  *
  171.  * BUGS:
  172.  *    None noticed.
  173.  *
  174.  * REVISIONS:
  175.  *
  176.  * $Log$ 
  177.  */
  178.  
  179. #include    <stdio.h>
  180.  
  181. ==============================================================================
  182.  
  183.         Template 4.    Main routine using simple I/O
  184.                 (created using -mi)
  185.  
  186. #ifndef    lint
  187. static    char    *    $n_$e_rcsid    =
  188. "$Header: $n.$e,v $r $y/$c/$d $h:$m:$s $w Exp $";
  189.  
  190. static    char    *    $n_$e_source    =
  191. "$Source$";
  192.  
  193. #endif
  194.  
  195. /*
  196.  * NAME:
  197.  *    $n
  198.  *
  199.  * SYNOPSIS:
  200.  *    $n [other option flags] string 
  201.  *
  202.  * DESCRIPTION:
  203.  *    "$n" does the following:
  204.  *    $u
  205.  * OPTIONS:
  206.  *    Describe any options on the command line. 
  207.  *
  208.  * AUTHOR:
  209.  *    $x
  210.  *
  211.  * BUGS:
  212.  *    None noticed.
  213.  *
  214.  * REVISIONS:
  215.  *
  216.  * $Log$ 
  217.  */
  218.  
  219. #include    <stdio.h>
  220. #include    <strings.h>
  221.  
  222. main        (argc, argv)
  223. int        argc;
  224. char    **    argv;
  225. {
  226.  
  227. /*
  228.  *    Functions.
  229.  */
  230.  
  231.  
  232. /*
  233.  *    Variables.
  234.  */
  235.  
  236.     FILE    *    instream;
  237.  
  238.     char    *    path;
  239.     char    *    program;
  240.     char    *    slash;
  241.  
  242. /*
  243.  *    Store the program name and remove it from the argument list.
  244.  */
  245.  
  246.     if (slash = rindex (*argv, '/'))
  247.         program = slash + 1;
  248.     else
  249.         program = *argv;
  250.  
  251.     argv++;
  252.     argc--;
  253.  
  254. /*
  255.  *    Either open an input file, or read "stdin".
  256.  */
  257.  
  258.     if (argc > 0)
  259.     {
  260.         path = *argv;
  261.         instream = fopen (path, "r");
  262.  
  263.         if (instream == (FILE *) NULL)
  264.         {
  265.             fprintf (stderr, "%s:  can't open\n", path);
  266.             exit (1);
  267.         }
  268.     }
  269.     else
  270.         instream = stdin;
  271.  
  272. /*
  273.  *    Processing.
  274.  */
  275.  
  276. $b
  277. /*
  278.  *    Close the input file, if it's not stdin.
  279.  */
  280.  
  281.     if (instream != stdin)
  282.         fclose (instream);
  283.  
  284.     exit (0);
  285. }
  286.  
  287. ==============================================================================
  288.  
  289.         Template 5.    Generic main routine (created using -mm)
  290.  
  291. #ifndef    lint
  292. static    char    *    $n_$e_rcsid    =
  293. "$Header: $n.$e,v $r $y/$c/$d $h:$m:$s $w Exp $";
  294.  
  295. static    char    *    $n_$e_source    =
  296. "$Source$";
  297.  
  298. #endif
  299.  
  300. /*
  301.  * NAME:
  302.  *    $n
  303.  *
  304.  * SYNOPSIS:
  305.  *    $n [other option flags] string 
  306.  *
  307.  * DESCRIPTION:
  308.  *    "$n" does the following:
  309.  *    $u
  310.  * OPTIONS:
  311.  *    Describe any options on the command line. 
  312.  *
  313.  * AUTHOR:
  314.  *    $x
  315.  *
  316.  * BUGS:
  317.  *    None noticed.
  318.  *
  319.  * REVISIONS:
  320.  *
  321.  * $Log$ 
  322.  */
  323.  
  324. $i
  325. #include    <strings.h>
  326. $p
  327. $g
  328.  
  329. main        (argc, argv)
  330. int        argc;
  331. char    **    argv;
  332. {
  333.  
  334. /*
  335.  *    Functions.
  336.  */
  337.  
  338. $f
  339. /*
  340.  *    Variables.
  341.  */
  342.  
  343.     char        *    ofile;
  344.     char        *    program;
  345.     char        *    slash;
  346.  
  347.     extern    char    *    optarg;
  348.     extern    int        optind;
  349.  
  350.     int                 c;
  351.     int                 errflg;
  352. $v
  353. /*
  354.  *    Store the program name.
  355.  */
  356.  
  357.     if (slash = rindex (*argv, '/'))
  358.         program = slash + 1;
  359.     else
  360.         program = *argv;
  361.  
  362. /*
  363.  *    Process the argument list.
  364.  */
  365.  
  366.     errflg = 0;
  367.  
  368.     while ((c = getopt (argc, argv, "abo:")) != -1)
  369.     {
  370.         switch (c)
  371.         {
  372.             case 'a':
  373.                 printf ("Read option 'a'\n");
  374.                 break;
  375.  
  376.             case 'b':
  377.                 printf ("Read option 'b'\n");
  378.                 break;
  379.  
  380.             case 'o':
  381.                 ofile = optarg;
  382.                 printf ("Read option 'o', arg is (%s)\n",
  383.                         ofile);
  384.                 break;
  385.  
  386.             case '?':
  387.                 errflg++;
  388.         }
  389.     }
  390.  
  391.     if (errflg)
  392.     {
  393.         (void) fprintf (stderr, "usage: %s ... file\n", program);
  394.         exit (2);
  395.     }
  396.  
  397.     for (; optind < argc; optind++)
  398.     {
  399.         printf ("File (%s)\n", argv[optind]);
  400.     }
  401.  
  402. /*
  403.  *    Main processing.
  404.  */
  405.  
  406. $b
  407.     exit (0);
  408. }
  409.  
  410. ==============================================================================
  411.  
  412.         Template 6.    Generic "stub" function (created using -ms)
  413.  
  414. #ifndef    lint
  415. static    char    *    $n_$e_rcsid    =
  416. "$Header: $n.$e,v $r $y/$c/$d $h:$m:$s $w Exp $";
  417.  
  418. static    char    *    $n_$e_source    =
  419. "$Source$";
  420.  
  421. #endif
  422.  
  423. /*
  424.  * NAME:
  425.  *    $n
  426.  *
  427.  * SYNOPSIS:
  428.  *    $t $n ($l)
  429.  *
  430.  * DESCRIPTION:
  431.  *    $u
  432.  *
  433.  * ARGUMENTS:
  434.  *    Describe any function arguments.
  435.  *
  436.  * AUTHOR:
  437.  *    $x
  438.  *
  439.  * BUGS:
  440.  *    None noticed.
  441.  *
  442.  * REVISIONS:
  443.  *
  444.  * $Log$ 
  445.  */
  446.  
  447. #include    <stdio.h>
  448. #include    <ctype.h>
  449.  
  450. int    $n ()
  451. {
  452.  
  453.     printf ("Entering function \"$n\"\n");
  454.     return (0);
  455. }
  456.